/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.OctetStringValue;
import de.thwildau.tm.moses.asn1.asn1.Value;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Octet String Value</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.OctetStringValueImpl#getBinString <em>Bin String</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.OctetStringValueImpl#getHexString <em>Hex String</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.OctetStringValueImpl#getAcontainingValue <em>Acontaining Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OctetStringValueImpl extends SimpleValueImpl implements OctetStringValue
{
  /**
   * The default value of the '{@link #getBinString() <em>Bin String</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBinString()
   * @generated
   * @ordered
   */
  protected static final String BIN_STRING_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getBinString() <em>Bin String</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBinString()
   * @generated
   * @ordered
   */
  protected String binString = BIN_STRING_EDEFAULT;

  /**
   * The default value of the '{@link #getHexString() <em>Hex String</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHexString()
   * @generated
   * @ordered
   */
  protected static final String HEX_STRING_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getHexString() <em>Hex String</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHexString()
   * @generated
   * @ordered
   */
  protected String hexString = HEX_STRING_EDEFAULT;

  /**
   * The cached value of the '{@link #getAcontainingValue() <em>Acontaining Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getAcontainingValue()
   * @generated
   * @ordered
   */
  protected Value acontainingValue;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected OctetStringValueImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.OCTET_STRING_VALUE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getBinString()
  {
    return binString;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBinString(String newBinString)
  {
    String oldBinString = binString;
    binString = newBinString;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.OCTET_STRING_VALUE__BIN_STRING, oldBinString, binString));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getHexString()
  {
    return hexString;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setHexString(String newHexString)
  {
    String oldHexString = hexString;
    hexString = newHexString;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.OCTET_STRING_VALUE__HEX_STRING, oldHexString, hexString));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Value getAcontainingValue()
  {
    return acontainingValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetAcontainingValue(Value newAcontainingValue, NotificationChain msgs)
  {
    Value oldAcontainingValue = acontainingValue;
    acontainingValue = newAcontainingValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE, oldAcontainingValue, newAcontainingValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setAcontainingValue(Value newAcontainingValue)
  {
    if (newAcontainingValue != acontainingValue)
    {
      NotificationChain msgs = null;
      if (acontainingValue != null)
        msgs = ((InternalEObject)acontainingValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE, null, msgs);
      if (newAcontainingValue != null)
        msgs = ((InternalEObject)newAcontainingValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE, null, msgs);
      msgs = basicSetAcontainingValue(newAcontainingValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE, newAcontainingValue, newAcontainingValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE:
        return basicSetAcontainingValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.OCTET_STRING_VALUE__BIN_STRING:
        return getBinString();
      case Asn1Package.OCTET_STRING_VALUE__HEX_STRING:
        return getHexString();
      case Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE:
        return getAcontainingValue();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.OCTET_STRING_VALUE__BIN_STRING:
        setBinString((String)newValue);
        return;
      case Asn1Package.OCTET_STRING_VALUE__HEX_STRING:
        setHexString((String)newValue);
        return;
      case Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE:
        setAcontainingValue((Value)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.OCTET_STRING_VALUE__BIN_STRING:
        setBinString(BIN_STRING_EDEFAULT);
        return;
      case Asn1Package.OCTET_STRING_VALUE__HEX_STRING:
        setHexString(HEX_STRING_EDEFAULT);
        return;
      case Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE:
        setAcontainingValue((Value)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.OCTET_STRING_VALUE__BIN_STRING:
        return BIN_STRING_EDEFAULT == null ? binString != null : !BIN_STRING_EDEFAULT.equals(binString);
      case Asn1Package.OCTET_STRING_VALUE__HEX_STRING:
        return HEX_STRING_EDEFAULT == null ? hexString != null : !HEX_STRING_EDEFAULT.equals(hexString);
      case Asn1Package.OCTET_STRING_VALUE__ACONTAINING_VALUE:
        return acontainingValue != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (binString: ");
    result.append(binString);
    result.append(", hexString: ");
    result.append(hexString);
    result.append(')');
    return result.toString();
  }

} //OctetStringValueImpl
